<template>
  <div class="cardbg">
    <!-- <img src="../assets/img/sea.jpg" class="artbg" /> -->
    <div class="maincontainer">
      <div class="left">
        <div slot="header">
          <router-link
            class="main-text"
            :to="'/post/' + article.id"
            v-html="'《'+ article.title + '》'"
          ></router-link>
          <div class="article-info">
            <el-tag effect="dark" size="mini">{{ article.type }}</el-tag>
            浏览量：{{ article.views }} || 分类：
            <router-link
              class="link secondary-text"
              :to="'/category/' + article.category"
            >
              {{ article.category }}</router-link
            >
          </div>
          <!-- <el-divider></el-divider> -->
        </div>

        <div class="tabloid">“{{ article.tabloid }}”</div>
        <div class="tags">
          <i class="el-icon-user-solid article-icon"> {{ article.author }}</i>
          <i class="el-icon-date article-icon"> {{ article.gmtCreate }} </i>
          <i class="el-icon-price-tag article-icon">
            <router-link
              class="tag"
              v-for="(tag, index) in article.tags"
              :key="index"
              v-text="tag"
              :to="'/tag/' + tag"
            ></router-link>
          </i>
        </div>
      </div>
      <div class="right">
        <img :src="photo" class="artbg" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "ArticleItem",
  props: ["article"],
  data() {
    return {
      imgurl: [
        "http://img.xiyblog.cn/img/10.jpg",
        "http://img.xiyblog.cn/img/19.jpg",
        "http://img.xiyblog.cn/img/20.jpg",
        "http://img.xiyblog.cn/img/21.jpg",
        "http://img.xiyblog.cn/img/24.jpg",
        "http://img.xiyblog.cn/img/4.jpg",

        "http://img.xiyblog.cn/img/1.jpg",
        "http://img.xiyblog.cn/img/12.jpg",
        "http://img.xiyblog.cn/img/13.jpg",
        "http://img.xiyblog.cn/img/14.jpg",
        "http://img.xiyblog.cn/img/15.jpg",
        "http://img.xiyblog.cn/img/27.jpg",

        "http://img.xiyblog.cn/img/28.jpg",
        "http://img.xiyblog.cn/img/29.jpg",
        "http://img.xiyblog.cn/img/3.jpg",
        "http://img.xiyblog.cn/img/30.jpg",
        "http://img.xiyblog.cn/img/6.jpg",
        "http://img.xiyblog.cn/img/7.jpg",

        "http://img.xiyblog.cn/img/8.jpg",
        "http://img.xiyblog.cn/img/9.jpg",
      ],
    };
  },
  created() {
    this.img = Math.floor(Math.random() * 20);
    this.photo = this.imgurl[this.img];
  },
};
</script>

<style scoped>
.tags {
  bottom: 12px;
  position: absolute;
}
.left {
  padding: 15px;
  max-width: 360px;
}
.right {
  width: 60%;
  max-width: 268px;
  overflow: hidden;
  border-radius: 6px;
}
.maincontainer {
  display: flex;
  /* flex-direction: row-reverse; */
  justify-content: space-between;
}
.el-card__body {
  /* margin-top: 20px;
  margin-bottom: 10px; */
  padding: 0;
}
.article-info {
  margin-top: 10px;
  color: #909399;
  font-size: 13px;
}
.article-icon,
.article-icon .tag {
  color: #909399;
  font-size: 13px;
  margin-right: 10px;
  text-decoration: none;
}
.article-icon .tag:hover {
  color: #409eff;
  cursor: pointer;
}
.tabloid {
  color: #606266;
  font-size: 24px;
  margin: 12px;
  overflow: hidden;

  text-overflow: ellipsis;
  white-space: nowrap;
}
.i {
  position: absolute;
  bottom: 2px;
}

.cardbg {
  /* background: radial-gradient(ellipse at top right,  #6190E8 10%,#fffeea  25%, #F2AA9D 30%); */
  background-color: #eee;
  opacity: 0.8;
  height: 200px;
  border-radius: 8px;
  transform-style: preserve-3d;
  transform-origin: top center;
  transition: transform 0.35s ease-in-out;
  position: relative;
  padding: 0px;
  margin-top: 18px;
}

/* .cardbg ::before {

    box-shadow: 0 6px 12px 12px rgba(0, 0, 0, 0.4);
    opacity: 0.9;
    transform-origin: top center;
    transition: 0.3s ease-in-out;
} */

.cardbg:hover ::before {
  opacity: 0.6;
  transform: rotateX(12deg) translateY(-8px) scale(3);
}

.cardbg:hover {
  transform: rotateX(12deg) translateY(-8px);
  opacity: 0.9;
}

.cardbg:hover::after {
  transform: translateY(100%);
}
.artbg {
  float: right;
  display: flex;
  justify-content: flex-end;
  height: 200px;
  object-fit: cover;
  border-radius: 6px;
  opacity: 0.9;
  /* position: absolute; */
}
</style>
